package sii.challenge.main;

import java.sql.DriverManager;
import java.sql.Connection;

/**
 * Attraverso questa classe si effettua il collegamento al DB
 * @author Daniele Midi, Antonio Tedeschi 
 * 
 */

public class DataSource {
        private String dbUri = "jdbc:mysql://localhost:3306/sii2013";
        private String username = "sii";
        private String password = "sii2013";

        /**
         * Metodo per la connessione al DataBase
         * @return una connessione al DataBase definito
         * @throws Exception
         */
        public Connection getConnection() throws Exception {
                Connection connection = null;
                try {
                        Class.forName("com.mysql.jdbc.Driver").newInstance();
                        connection = DriverManager.getConnection(dbUri, username, password);
                } catch (Exception e) {
                        System.err.println("Exception: " + e.getMessage());
                }
                return connection;
        }
}